using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using Abp.Threading.BackgroundWorkers;
using Yozeev.Authorization;
using Yozeev.Authorization.Permissions.Dtos.CustomMapper;
using Yozeev.BusinessLogic.Authorization;
using Yozeev.BusinessLogic.Mapper;
using Yozeev.CustomDtoAutoMapper;
using Yozeev.Editions.Mapper;
using Yozeev.Languages.Dtos.CustomMapper;
using Yozeev.MultiTenancy.Mapper;
using Yozeev.Organizations.Dtos.CustomMapper;
using Yozeev.PhoneBooks.Books.Authorization;
using Yozeev.PhoneBooks.Books.Mapper;
using Yozeev.SystemConfig.Authorization;
using Yozeev.SystemConfig.BasicConfig.Authorization;
using Yozeev.SystemConfig.BasicConfig.Mapper;
using Yozeev.SystemConfig.Mapper;
using Yozeev.SystemConfig.SystemRecord.Authorization;
using Yozeev.SystemConfig.SystemRecord.Mapper;
using Yozeev.WechatManagement.WechatAppConfigs.Authorization;
using Yozeev.WechatManagement.WechatAppConfigs.Mapper;
using Yozeev.WechatManagement.WechatMenus.Mapper;

namespace Yozeev
{
    [DependsOn (
        typeof (YozeevCoreModule),
        typeof (AbpAutoMapperModule))]
    public class YozeevApplicationModule : AbpModule {
        public override void PreInitialize () {

            // 权限认证提供者
            Configuration.Authorization.Providers.Add<AppProAuthorizationProvider> ();

            // ================== Wechat模块权限 =====================
            Configuration.Authorization.Providers.Add<WechatAppConfigAuthorizationProvider> ();

            // ================== Book模块权限 =====================

            Configuration.Authorization.Providers.Add<BooksAuthorizationProvider>();
            // ================== PayMethod 支付方式模块权限 =====================
            Configuration.Authorization.Providers.Add<PayMethodAuthorizationProvider>();
            // ================== DateDictionary 模块权限 =====================
            Configuration.Authorization.Providers.Add<DateDictionaryAuthorizationProvider>();
            // ================== CheckRecord 模块权限 =====================
            Configuration.Authorization.Providers.Add<CheckRecordAuthorizationProvider>();
            // ================== ClientVersion 模块权限 =====================
            Configuration.Authorization.Providers.Add<ClientVersionAuthorizationProvider>();
            // ================== Branch 模块权限 =====================
            Configuration.Authorization.Providers.Add<BranchAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<BranchUserAuthorizationProvider>();

            // ================== Boat 模块权限 =====================
            Configuration.Authorization.Providers.Add<BoatAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<RouteAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<ScheduleAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<WharfAuthorizationProvider>();

            // ================== Device 模块权限 =====================
            Configuration.Authorization.Providers.Add<DeviceAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<GateRecordAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<VerifiableSetAuthorizationProvider>();
            // ================== common 模块权限 =====================
            Configuration.Authorization.Providers.Add<CustomerAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<ScenicSpotAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<SourceAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<CommonCustomerAuthorizationProvider>();
            // ================== Ticket 模块权限 =====================
            Configuration.Authorization.Providers.Add<AccountAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<AccountDetailAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<ActivityAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<ActivityDetailAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<ActivityTempAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<ActivityTempDetailAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<PriceAuditAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketDetailAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketDetailHistoryAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketIntroduceAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketPriceAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketStationAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketStationEnableAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketUserEnableAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketScheduleEnableAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TicketRoleAuthorizationProvider>();
            // ================== TravelManagement 模块权限 =====================
            Configuration.Authorization.Providers.Add<RechargeRecordAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TravelAgencyAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TravelTicketDetailAuthorizationProvider>();
            // ================== Power 模块权限 =====================
            Configuration.Authorization.Providers.Add<MenuAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<PowerAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<PowerRoleAuthorizationProvider>();
            // ================== Print 模块权限 =====================
            Configuration.Authorization.Providers.Add<PrintStyleAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<PrintStyleChildAuthorizationProvider>();


            // 自定义类型映射
            Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration =>
            {

                // 系统通用的Dto映射
                CustomerAppDtoMapper.CreateMappings(configuration);

                // 版本
                CustomEditionMapper.CreateMappings(configuration);

                // Add your custom AutoMapper mappings here...

             

                // Permission
                CustomerPermissionsMapper.CreateMappings (configuration);

                // OrganizationUnit
                CustomerOranizationMapper.CreateMappings (configuration);

                // Tenant
                TenantMapper.CreateMappings (configuration);

                // ================== Wechat =====================
                WechatAppConfigMapper.CreateMappings (configuration);
                WechatMenuMapper.CreateMappings (configuration);

                // ================== Book对象映射 =====================
              
                BookMapper.CreateMappings(configuration);


                // ================== PayMethod 对象映射 =====================
                PayMethodMapper.CreateMappings(configuration);
                // ================== DateDictionary 对象映射 =====================
                DateDictionaryMapper.CreateMappings(configuration);
                // ================== DateDictionary 对象映射 =====================
                ClientVersionMapper.CreateMappings(configuration);
                // ================== Branch 对象映射 =====================
                BranchMapper.CreateMappings(configuration);
                BranchUserMapper.CreateMappings(configuration);
                // ================== CheckRecord 对象映射 =====================
                CheckRecordMapper.CreateMappings(configuration);

                // ================== Boat 对象映射 =====================
                BoatMapper.CreateMappings(configuration);
                RouteMapper.CreateMappings(configuration);
                ScheduleMapper.CreateMappings(configuration);
                WharfMapper.CreateMappings(configuration);
                // ================== Device 对象映射 =====================
                DeviceMapper.CreateMappings(configuration);
                GateRecordMapper.CreateMappings(configuration);
                VerifiableSetMapper.CreateMappings(configuration);
                // ================== common 对象映射 =====================
                CustomerMapper.CreateMappings(configuration);
                ScenicSpotMapper.CreateMappings(configuration);
                SourceMapper.CreateMappings(configuration);
                CommonCustomerMapper.CreateMappings(configuration);
                // ================== Ticket 对象映射 =====================
                AccountMapper.CreateMappings(configuration);
                AccountDetailMapper.CreateMappings(configuration);
                ActivityMapper.CreateMappings(configuration);
                ActivityDetailMapper.CreateMappings(configuration);
                ActivityTempMapper.CreateMappings(configuration);
                ActivityTempDetailMapper.CreateMappings(configuration);
                PriceAuditMapper.CreateMappings(configuration);
                TicketMapper.CreateMappings(configuration);
                TicketDetailMapper.CreateMappings(configuration);
                TicketDetailHistoryMapper.CreateMappings(configuration);
                TicketIntroduceMapper.CreateMappings(configuration);
                TicketPriceMapper.CreateMappings(configuration);
                TicketStationMapper.CreateMappings(configuration); 
                TicketStationEnableMapper.CreateMappings(configuration);
                TicketUserEnableMapper.CreateMappings(configuration);
                TicketScheduleEnableMapper.CreateMappings(configuration);
                TicketRoleMapper.CreateMappings(configuration);
                // ================== TravelManagement 对象映射 =====================
                RechargeRecordMapper.CreateMappings(configuration);
                TravelAgencyMapper.CreateMappings(configuration);
                TravelTicketDetailMapper.CreateMappings(configuration);
                // ================== Power 对象映射 =====================
                MenuMapper.CreateMappings(configuration);
                PowerMapper.CreateMappings(configuration);
                PowerRoleMapper.CreateMappings(configuration);
                // ================== Print 对象映射 =====================
                PrintStyleDtoAutoMapper.CreateMappings(configuration);
                PrintStyleChildDtoAutoMapper.CreateMappings(configuration);
            });

        }

        public override void Initialize () {
            var thisAssembly = typeof (YozeevApplicationModule).GetAssembly ();

            IocManager.RegisterAssemblyByConvention (thisAssembly);


          


            Configuration.Modules.AbpAutoMapper ().Configurators.Add (
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddProfiles (thisAssembly)
            );
        }

        public override void PostInitialize () {
            //var workManager = IocManager.Resolve<IBackgroundWorkerManager> ();
          //  workManager.Add(IocManager.Resolve<TestAutoLoggerPassiveWorker>());
        }
    }
}